package com.kyxx.topics.activity;

import android.support.v4.app.Fragment;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.kyxx.topics.BaseActivity;
import com.kyxx.topics.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/11/21.
 */
public class FeedBackActivity extends BaseActivity {
    @Bind(R.id.iv_back)
    ImageView iv_back;
    @Bind(R.id.tv_feed_back_opinion)
    TextView tv_feed_back_opinion;
    @Bind(R.id.v_feed_back_opinion)
    View v_feed_back_opinion;
    @Bind(R.id.rl_feed_back_opinion)
    RelativeLayout rl_feed_back_opinion;
    @Bind(R.id.tv_feed_back_problem)
    TextView tv_feed_back_problem;
    @Bind(R.id.v_feed_back_problem)
    View v_feed_back_problem;
    @Bind(R.id.rl_feed_back_problem)
    RelativeLayout rl_feed_back_problem;
    private Fragment[] mFragments;
    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.activity_feed_back);
        ButterKnife.bind(this);
    }

    @Override
    protected void findViewById() {

    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void processLogic() {
        mFragments = new Fragment[2];
        mFragments[0] = getSupportFragmentManager().findFragmentById(R.id.fragment_opinion);
        mFragments[1] = getSupportFragmentManager().findFragmentById(R.id.fragment_problem);
        showFragment(0);
        setTextColor(0,true);
    }


    @OnClick({R.id.iv_back, R.id.rl_feed_back_opinion, R.id.rl_feed_back_problem})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.iv_back:
                finish();
                break;
            case R.id.rl_feed_back_opinion:
                showFragment(0);
                setTextColor(0,true);
                break;
            case R.id.rl_feed_back_problem:
                showFragment(1);
                setTextColor(1,true);
                break;
        }
    }
    private void showFragment(int i){
        getSupportFragmentManager().beginTransaction()
                .show(mFragments[i])
                .hide(mFragments[1])
                .hide(mFragments[0])
                .commit();
    }
    private void setTextColor(int i,boolean click){
        tv_feed_back_opinion.setTextColor(getResources().getColor(R.color.color999999));
        v_feed_back_opinion.setVisibility(View.GONE);
        tv_feed_back_problem.setTextColor(getResources().getColor(R.color.color999999));
        v_feed_back_problem.setVisibility(View.GONE);
        if(i == 0){
            tv_feed_back_opinion.setTextColor(click?getResources().getColor(R.color.colorPrimary):getResources().getColor(R.color.color999999));
            v_feed_back_opinion.setVisibility(click?View.VISIBLE:View.GONE);
        }else {
            tv_feed_back_problem.setTextColor(click?getResources().getColor(R.color.colorPrimary):getResources().getColor(R.color.color999999));
            v_feed_back_problem.setVisibility(click?View.VISIBLE:View.GONE);
        }


    }
}
